{
 "cells": [
  {
   "cell_type": "raw",
   "id": "aefd9029",
   "metadata": {},
   "source": [
    "Wifi & Password\n",
    "id: MR2\n",
    "password: AwsNjm19"
   ]
  },
  {
   "cell_type": "raw",
   "id": "dc7dfdac",
   "metadata": {},
   "source": [
    "物联网\n",
    "\n",
    "1. 物联网通讯协议\n",
    " - nbIoT 窄带物联网\n",
    " - MQTT\n",
    " - ZigBee 智慧家居\n",
    " - Wifi \n",
    "  1. 稳定性\n",
    "  2. 长通讯\n",
    "  3. 费电\n",
    "  4. 贵\n",
    "  \n",
    "2. 物联网架构\n",
    "  传感器\n",
    "  ↓\n",
    "  云端（农场）\n",
    "  ↓\n",
    "  客户端"
   ]
  },
  {
   "cell_type": "raw",
   "id": "e8a59d2a",
   "metadata": {},
   "source": [
    "云端地址：http://farm.0531yun.cn/#/\n",
    "数据结构\n",
    "Json → 包裹了引号的字典\n",
    "字典的本质 → “键值对”   键(Key):值(Value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "394ecb91",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "adict = {'林聪锦':6,'爱好':'唱跳打篮球','成绩':'优异'}\n",
    "adict['林聪锦']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "53732302",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'小公举'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# json 字典\n",
    "jail = {'房间号':123,\n",
    "        '关押信息':'某人','具体情况':[{'姓名':'小公举','关押时间':'两年半'}]}\n",
    "jail['具体情况'][0]['姓名']"
   ]
  },
  {
   "cell_type": "raw",
   "id": "c844c304",
   "metadata": {},
   "source": [
    "数据的获取\n",
    "1. 获取公共数据\n",
    "2. 获取私有数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "7c987de9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<bound method Response.json of <Response [200]>>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import requests as r\n",
    "# 获取公共数据的方法\n",
    "r.get('http://news.baidu.com')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "9a3190b8",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'347.000'"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import requests as r\n",
    "# 获取私有数据的方法\n",
    "url = 'http://farm.0531yun.cn/UserDevice/WeatherDeviceRealData'\n",
    "dev = {'deviceAddr':'40220829'}\n",
    "token = {'token':'995791667195921017'}\n",
    "data = r.get(url,params=dev,headers=token).json()\n",
    "group = 8\n",
    "name = 'tem'\n",
    "data['data']['terms'][group][name]\n",
    "#r.get(url,dev).text"
   ]
  },
  {
   "cell_type": "raw",
   "id": "cabb64a7",
   "metadata": {},
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
